package com.yihu.wlyy.web.common.im;


import org.json.JSONObject;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.yihu.wlyy.util.HttpUtil;
import com.yihu.wlyy.web.BaseController;

@RestController
@RequestMapping(value = "common")
public class imController extends BaseController {
	
	private static String host = "http://172.19.103.76:3000";
	
	@RequestMapping(value="/send_bus_msg")
	public String sendBusinessMsg(String userId,String content)
	{
		try{
			String _url = host+"/system/sendmsg.im";
			String param = "user_id="+userId+"&content="+content;
			String result = HttpUtil.sendPost(_url, param);
		
			JSONObject jb = new JSONObject(result);
			String errno = jb.get("errno").toString();
			String errorMsg = jb.get("errmsg").toString();
			if(!errno.equals("0"))
			{
				return error(-1,errorMsg);
			}
			
			return success("推送成功!");
		}
		catch(Exception ex)
		{
			error(ex);
			return invalidUserException(ex, -1, "保存失败！");
		}
	}
	
	@RequestMapping(value="/send_chat_msg")
	public String sendChatMsg(String userId,String content)
	{
		return "";
	}
}
